package com.cy;

import com.cy.pojo.Student;
import com.cy.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @Author 张鹏宇
 * @Date 2021/3/28 16:33
 */
public class Test02 {
    public static void main(String[] args) throws Exception {


//        5.获取SqlSession对象，从SqlSessionFactory中获取Session对象
        SqlSession sqlSession = MybatisUtils.getSqlSession();

//        6.指定执行的SQL 语句
        String sqlid = "com.cy.dao.StudentDao" + "." + "selectFindAll";

//        7.[!!!重要!!!]执行SQL语句
        List<Student> selectList = sqlSession.selectList(sqlid);
//        List<studen> objects = sqlSession.selectList(sqlid);

//        8.遍历结果集(lambda表达式foreach)
        selectList.forEach(System.out :: println);

//        9.关闭资源
        sqlSession.close();

    }
}
